import { getRGBNum } from "@/components/formGenerator/utils";

const app = {
  state: {
    formData: null, // 表单设计预览存储内容
    activeData: '', // 选中数据
    activeId: '', // 选中id
    drawingList: [], // 用于存储拖拽过程中的表单组件列表
    cssList: [], // 用于存储全部样式
    eventList: [], // 用于存储全部事件
    themeColor: '', // 主题色
    selectedColor: '',
  },

  mutations: {
    SET_FORMDATA(state, formData) {
      state.formData = formData
    },
    SET_ACTIVEDATA(state, activeData) {
      console.log("我放入数据了--->SET_ACTIVEDATA")
      if (activeData.__config__.formId) {
        state.activeId = activeData.__config__.formId
      }
      state.activeData = activeData
    },
    SET_ACTIVEID(state, activeId) {
      state.activeId = activeId
    },
    SET_DRAWINGLIST(state, drawingList) {
      state.drawingList = drawingList
    },
    SET_CSSLIST(state, cssList) {
      state.cssList = cssList
    },
    SET_EVENTLIST(state, eventList) {
      state.eventList = eventList
    },
    SET_THEMECOLOR(state, themeColor) {
      state.themeColor = themeColor
      const { r, g, b } = getRGBNum(themeColor);
      const selectedColor = `rgba(${r}, ${g}, ${b}, 0.08)`
      state.selectedColor = selectedColor
    },
  },
  actions: {

  }
}

export default app
